package net.sx.minemodule.mvp.bean;

import android.text.Html;
import android.text.Spanned;

import com.kedll.library.crop.FileUtil;

import java.io.File;

/**
 * 描述: 选择的售后提交图片
 * author:胡邦茂
 * CreateDate:2019年07月11日 17:53
 */
public class CheckRequestImg {
    //源文件路径用于判断是否重复选择
    private String sourceFileAbsPath;
    //要上传的压缩图片路径
    private File file;
    private String url;
    private int res;
    //1 上传中 2上传成功 3上传失败
    public static final int STATUS_LOADING = 1, STATUS_OK = 2, STATUS_ERR = 3;
    private int status;

    public CheckRequestImg(int status, File file) {
        this.file = file;
        this.status = status;
    }

    public CheckRequestImg(File file, int res) {
        this.file = file;
        this.res = res;
    }

    public String getSourceFileAbsPath() {
        return sourceFileAbsPath == null ? "" : sourceFileAbsPath;
    }

    public void setSourceFileAbsPath(String sourceFileAbsPath) {
        this.sourceFileAbsPath = sourceFileAbsPath;
    }

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getRes() {
        return res;
    }

    public void setRes(int res) {
        this.res = res;
    }

    public long getFileSize() {
        return FileUtil.getFileSize(getFile());
    }

    public String getFileName() {
        return FileUtil.getFileName(getFile().getAbsolutePath());
    }

    public String getFileMD5() {
        return FileUtil.getFileMD5(getFile());
    }

    public Spanned getStatusMsg() {
        String msg = "";
        switch (getStatus()) {
            case STATUS_LOADING:
                msg = "上传中";
                break;
            case STATUS_OK:
                msg = "<span style='color:#a541c9'>上传成功</span>";
                break;
            case STATUS_ERR:
                msg = "<span style='color:red'>点击重试</span>";
                break;
        }

        return Html.fromHtml(msg);
    }
}
